package com.ceba.test.modules.email.helper;

import java.util.Map;

import com.ceba.test.modules.email.entity.MsgEmailSet;
import com.ceba.test.modules.email.entity.MsgMail;
import com.ceba.test.modules.email.logicService.EmailLogicService;

import configs.context.SpringBeans;

public class MailHelper {

	private static EmailLogicService emailLogicService = SpringBeans.getEmailLogicService("emailLogicService");
	
	public static  String parseEmailHtml(MsgEmailSet msgMailSet, String title, String txt) {
		String html=msgMailSet.getContextTemplate();
		if(title.equals("")){
			title=msgMailSet.getTitle();
		}
		html=html.replace("#TITLE#", title).replace("#CONTEXT#", txt);
		return html;
	}
	
	/**
	 * 发送报告附件
	 * @param title
	 * @param mailBody
	 * @param filePaths
	 * @param mailTo
	 * @param loginUserId
	 * @return
	 */
	public static boolean sendEmailAttach(String title, String mailBody,
			Map<String,String>filePaths, String mailTo,String loginUserId) {

		return emailLogicService.sendEmailAttach(title,mailBody,filePaths,mailTo, loginUserId);
	}
	
	/**
	 * 添加一个常用的EMAIL
	 * @param mail email
	 * @return
	 */
	public static Boolean addSendEMail(String mail,String loginUserId)throws Exception{
		return emailLogicService.addSendEMail(mail,loginUserId);

	}
	
	public static Boolean sendEmails(String title,String mailBody,String path[],
			String mailTo,String[] reportName,String loginUserId)  {
		return emailLogicService.sendEmails(title, mailBody, path, mailTo, reportName,loginUserId);
	}
	/**
	 * 发送邮件：
	 * 邮件内容为HTML
	 * html内嵌文件 例如 <img src="" />
	 * @param title
	 * @param mailBody
	 * @param path
	 * @param mailTo 多个收件人请用;隔开
	 * @param reportName
	 * @param htmlPath
	 * @return
	 */
	public static boolean sendEmailHtmlFile(String title,String mailBody,String path[],
			String mailTo,String[] reportName,String[] htmlPath,String loginUserId)throws Exception{
		return emailLogicService.sendEmailHtmlFile(title, mailBody, path, mailTo, reportName,htmlPath,loginUserId);
	}
	
	/**
	 * 获取msg_mail的单个信息
	 * 
	 */
	public static MsgMail getMsgMailById(String id) throws Exception{
	   return  emailLogicService.getMsgMailById(id);
	}

}
